/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package eulerframework;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.net.HttpCookie;

/**
 *
 * @author Thor
 */
public class CookieHandler {

    private static HttpCookie cookie = null;

    public HttpCookie loadCookie() {
        //TODO: FIX!
        if (cookie != null) {
            return cookie;
        }
        try {
            File f = new File("cookieData.dat");
            ObjectInputStream input = new ObjectInputStream(new FileInputStream(f));
            cookie = (HttpCookie) input.readObject();
            return cookie;
        } catch (FileNotFoundException ex) {
            //requires user login
        } catch(IOException ex){
            ex.printStackTrace();
        } catch(ClassNotFoundException ex){
            //requires user login
        }
        return cookie;
    }
}
